/**
 * Copyright (C), 2019-2020, 宇信融汇
 * FileName: StaticClassDemo
 * Author:   xbliu
 * Date:     2020/6/30 11:47
 * Description: 静态内部类
 * History:
 * <author>          <time>          <version>          <desc>
 * xbliu           修改时间           版本号              描述
 */
package c_007.innerclass;

/**
 * @Classname StaticClassDemo
 * @Description TODO
 * @Date 2020/6/30 11:47
 * @Created by xbliu
 */
public class StaticClassDemo {
    static int outer_i = 100;//类变量
    private int id;

    public void outer() {
        System.out.println("外部类方法");
    }

    public static void outer_f1()//类方法
    {
    }

    public void outer_f2()//成员方法
    {
    }
    public void outer_f3()//成员方法
    {
        // 外部类访问内部类的静态成员：内部类.静态成员
        System.out.println(StaticDemo.age);
        StaticDemo.inner_f0();
        StaticDemo staticDemo = new StaticDemo();
        staticDemo.inner_f1();

    }

    static class StaticDemo {
        private String name;
        static int age = 10;

        public void inner() {
            System.out.println("内部类方法");
        }
        public static void inner_f0() {
            System.out.println("内部类方法");
        }

        public void inner_f1() {
            //静态内部类只能访问外部类的静态成员(包括静态变量和静态方法)
            outer_f1();
            System.out.println(outer_i);
            System.out.println("内部类方法");
        }

        public void inner_f2() {
            // 静态内部类不能访问外部类的非静态成员(包括非静态变量和非静态方法)
            //outer_f2();

        }
    }


    public static void main(String[] args) {
       StaticClassDemo.StaticDemo staticDemo = new StaticDemo();
//        StaticDemo staticDemo = new StaticClassDemo.StaticDemo();
        staticDemo.inner();
    }
}
